if (widget == NULL)
return attributes;
- if (GTK_IS_ENTRY (widget) || GTK_IS_SEARCH_ENTRY (widget))
+ /* Subclasses of GtkEntryAccessible will chain up, so we need to protect
+ * the placeholder-text property access
+ */
+ if (GTK_IS_ENTRY (widget))
g_object_get (widget, "placeholder-text", &text, NULL);
if (text == NULL)
static void
gtk_entry_accessible_class_init (GtkEntryAccessibleClass *klass)
{
- AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
--- /dev/null
+/* gtksearchentryaccessible.c: GtkWidgetAccessible for GtkSearchEntry
+ *
+ * Copyright 2020 GNOME Foundation
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtksearchentryaccessible.h"
+
+#include "gtkintl.h"
+
+struct _GtkSearchEntryAccessible
+{
+ GtkEntryAccessible parent_instance;
+};
+
+G_DEFINE_TYPE (GtkSearchEntryAccessible, gtk_search_entry_accessible, GTK_TYPE_ENTRY_ACCESSIBLE)
+
+static AtkAttributeSet *
+gtk_search_entry_accessible_get_attributes (AtkObject *accessible)
+{
+ GtkWidget *widget;
+ AtkAttributeSet *attributes;
+ AtkAttribute *placeholder_text;
+ char *text = NULL;
+
+ attributes = ATK_OBJECT_CLASS (gtk_search_entry_accessible_parent_class)->get_attributes (accessible);
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
+ if (widget == NULL)
+ return attributes;
+
+ g_object_get (widget, "placeholder-text", &text, NULL);
+ if (text == NULL)
+ return attributes;
+
+ placeholder_text = g_malloc (sizeof (AtkAttribute));
+ placeholder_text->name = g_strdup ("placeholder-text");
+ placeholder_text->value = text;
+
+ attributes = g_slist_append (attributes, placeholder_text);
+
+ return attributes;
+}
+
+static void
+gtk_search_entry_accessible_class_init (GtkSearchEntryAccessibleClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ class->get_attributes = gtk_search_entry_accessible_get_attributes;
+}
+
+static void
+gtk_search_entry_accessible_init (GtkSearchEntryAccessible *self)
+{
+ AtkObject *atk_obj = ATK_OBJECT (self);
+
+ atk_obj->role = ATK_ROLE_TEXT;
+ atk_object_set_name (atk_obj, _("Search"));
+}
--- /dev/null
+/* gtksearchentryaccessible.h: A GtkWidgetAccessible for GtkSearchEntry
+ *
+ * Copyright 2020 GNOME Foundation
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk-a11y.h> can be included directly."
+#endif
+
+#include <gtk/a11y/gtkentryaccessible.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SEARCH_ENTRY_ACCESSIBLE (gtk_search_entry_accessible_get_type())
+#define GTK_SEARCH_ENTRY_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SEARCH_ENTRY_ACCESSIBLE, GtkSearchEntryAccessible))
+#define GTK_IS_SEARCH_ENTRY_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SEARCH_ENTRY_ACCESSIBLE))
+
+typedef struct _GtkSearchEntryAccessible GtkSearchEntryAccessible;
+typedef struct _GtkSearchEntryAccessibleClass GtkSearchEntryAccessibleClass;
+
+struct _GtkSearchEntryAccessibleClass
+{
+ GtkEntryAccessibleClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_search_entry_accessible_get_type (void) G_GNUC_CONST;
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GtkSearchEntryAccessible, g_object_unref)
+
+G_END_DECLS
'gtkscalebuttonaccessible.c',
'gtkscrollbaraccessible.c',
'gtkscrolledwindowaccessible.c',
+ 'gtksearchentryaccessible.c',
'gtkspinbuttonaccessible.c',
'gtkspinneraccessible.c',
'gtkstackaccessible.c',
'gtkscalebuttonaccessible.h',
'gtkscrollbaraccessible.h',
'gtkscrolledwindowaccessible.h',
+ 'gtksearchentryaccessible.h',
'gtkspinbuttonaccessible.h',
'gtkspinneraccessible.h',
'gtkstackaccessible.h',
#include <gtk/a11y/gtkscalebuttonaccessible.h>
#include <gtk/a11y/gtkscrolledwindowaccessible.h>
#include <gtk/a11y/gtkscrollbaraccessible.h>
+#include <gtk/a11y/gtksearchentryaccessible.h>
#include <gtk/a11y/gtkspinbuttonaccessible.h>
#include <gtk/a11y/gtkspinneraccessible.h>
#include <gtk/a11y/gtkstackaccessible.h>
#include "gtkmarshalers.h"
#include "gtkstylecontext.h"
#include "gtkeventcontrollerkey.h"
-#include "a11y/gtkentryaccessible.h"
+#include "a11y/gtksearchentryaccessible.h"
/**
}
}
-static AtkObject *
-gtk_search_entry_get_accessible (GtkWidget *widget)
-{
- AtkObject *atk_obj;
-
- atk_obj = GTK_WIDGET_CLASS (gtk_search_entry_parent_class)->get_accessible (widget);
- atk_object_set_name (atk_obj, _("Search"));
-
- return atk_obj;
-}
-
static gboolean
gtk_search_entry_grab_focus (GtkWidget *widget)
{
object_class->get_property = gtk_search_entry_get_property;
object_class->set_property = gtk_search_entry_set_property;
- widget_class->get_accessible = gtk_search_entry_get_accessible;
widget_class->grab_focus = gtk_search_entry_grab_focus;
widget_class->mnemonic_activate = gtk_search_entry_mnemonic_activate;
"stop-search",
NULL);
- gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SEARCH_ENTRY_ACCESSIBLE);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_css_name (widget_class, I_("entry"));
}